// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import { game } from "../../../script/game/control/game";
import { mapType } from "../../../script/game/gameType";
import { ListItem } from "../../../script/util/ListView/ListItem";
import { ccs } from "../../../script/util/services";
import mapWin from "./mapWin";

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends ListItem<mapType> {
    
    

    @property(cc.Label)
    locationName: cc.Label = null;

    @property(cc.Label)
    locationDesc: cc.Label = null;
    
    @property(cc.Sprite)
    icon: cc.Sprite = null;
    
    @property(cc.Sprite)
    location: cc.Sprite = null;
    
    start () {

    }
    initItem(data: mapType, index: number) {
        if(!data.desc) {
            data.desc = "神秘的地方";
        }
        this.locationName.string = data.name;
        this.locationDesc.string = data.desc;
        // ccs.spriteExd.setSprite(this.icon.node, `ui/house/${data.icon}`);
        
        this.node.on(cc.Node.EventType.TOUCH_START, () => {
           
        })
    }
    onItemclick(data: mapType) {
        //点击前往目的地
        // game.playerMgr.moveToLocation(data.id);
        //关闭地图
        // ccs.winMgr.closeWin('mapWin');
        this.intoShop(data.type, data.map);
    }
    intoShop(type, map) {
        // ccs.winMgr.showWin(`${map}Map`, { type }); //进入详情
        this.node.parent.parent.parent.parent.getComponent(mapWin).changeItems(type);
    }
}
